package com.blakequ.androidblemanager.utils;

public class BeaconModel implements Comparable<BeaconModel> {
    String major;
    String minor;
    int rssi;

    public BeaconModel() {
    }

    public BeaconModel(String major, String minor, int rssi) {
        this.major = major;
        this.minor = minor;
        this.rssi = rssi;
    }

    private BeaconModel(Builder builder) {
        setMajor(builder.major);
        setMinor(builder.minor);
        setRssi(builder.rssi);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getMajor() {
        return major == null ? "" : major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public String getMinor() {
        return minor == null ? "" : minor;
    }

    public void setMinor(String minor) {
        this.minor = minor;
    }

    public int getRssi() {
        return rssi;
    }

    public void setRssi(int rssi) {
        this.rssi = rssi;
    }

    public static final class Builder {
        private String major;
        private String minor;
        private int rssi;

        private Builder() {
        }

        public Builder major(String val) {
            major = val;
            return this;
        }

        public Builder minor(String val) {
            minor = val;
            return this;
        }

        public Builder rssi(int val) {
            rssi = val;
            return this;
        }

        public BeaconModel build() {
            return new BeaconModel(this);
        }
    }

    @Override
    public int compareTo(BeaconModel user) {           //重写Comparable接口的compareTo方法，
        return this.rssi - user.getRssi();// 根据年龄升序排列，降序修改相减顺序即可
    }
}
